/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.msk.wlhy.service;


import com.msk.common.utils.StringUtils;
import com.msk.sys.domain.User;
import com.msk.sys.service.CrudService;
import com.msk.wlhy.domain.HtLogisticsOrderDetail;
import com.msk.wlhy.domain.LogisticsOrderDetailedSummary;
import com.msk.wlhy.mapper.HtLogisticsOrderDetailDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * <p>[]</p>
 * <p>作者：zkp</p>
 * <p>邮箱：zkp@xiangyou.com</p>
 * <p>创建时间： 2018-06-07 </p>
 * <p>类说明：物流订单明细Service </p>
 * <p>修改记录：</p>
 */
@Service
@Transactional(readOnly = true)
public class HtLogisticsOrderDetailService extends CrudService<HtLogisticsOrderDetailDao, HtLogisticsOrderDetail> {

	@Autowired
	private HtLogisticsOrderDetailDao htLogisticsOrderDetailDao;

	public HtLogisticsOrderDetail get(String id) {
		return super.get(id);
	}
	
	public List<HtLogisticsOrderDetail> findList(HtLogisticsOrderDetail htLogisticsOrderDetail) {
		return dao.findList(htLogisticsOrderDetail);
	}
	
	public Long findCount(HtLogisticsOrderDetail htLogisticsOrderDetail){
		return dao.findCount(htLogisticsOrderDetail);
	}
	
//	public Page<HtLogisticsOrderDetail> auPage (Page<HtLogisticsOrderDetail> page, HtLogisticsOrderDetail htLogisticsOrderDetail) {
//		return super.findPage(page, htLogisticsOrderDetail);
//	}

	public List<HtLogisticsOrderDetail> shippingOrderPage (HtLogisticsOrderDetail htLogisticsOrderDetail) {
		User u = new User();
		//货主及子账号查看运单信息
		if(u != null && u.getUserIdentity() != null && "2".equalsIgnoreCase(u.getUserIdentity())){
			htLogisticsOrderDetail.setAttstr04(u.getId());
			htLogisticsOrderDetail.setAttstr05("1");
		}else if(u != null && StringUtils.isNotBlank(u.getMainAccountId()) && "0".equalsIgnoreCase(u.getAccountType()) ){
			htLogisticsOrderDetail.setAttstr04(u.getId());
			htLogisticsOrderDetail.setAttstr05(u.getFatherOfficeId());
		}
		return dao.findOrderList(htLogisticsOrderDetail);
	}

	public HtLogisticsOrderDetail getOrderInfo(String id) {
		return dao.getOrderInfo(id);
	}

	@Transactional(readOnly = false)
	public void save(HtLogisticsOrderDetail htLogisticsOrderDetail) {
		super.save(htLogisticsOrderDetail);
	}
	
	@Transactional(readOnly = false)
	public void delete(HtLogisticsOrderDetail htLogisticsOrderDetail) {
		super.delete(htLogisticsOrderDetail);
	}
	
	@Transactional(readOnly = false)
	public int deleteIds(String[] ids) {
		int result = 0;
		for (String id : ids) {
			super.delete(new HtLogisticsOrderDetail(id));
			result ++;
		}
		return result;
	}
	/**
	 * @description getDataByBar
	 * @date 2018-10-26
	 * @author chuming
	 * @param htLogisticsOrderDetail
	 * @return
	 */
	public List<Map<String, Object>> getDataByBar(HtLogisticsOrderDetail htLogisticsOrderDetail) {
		return dao.getDataByBar(htLogisticsOrderDetail);
	}
	/**
	 * @description findListByProfit
	 * @date 2018-10-26
	 * @author chuming
	 * @param htLogisticsOrderDetail
	 * @return
	 */
//	public Page<LogisticsOrderDetailedSummary> getLogisticsOrderDetailedSummaryPage (Page<LogisticsOrderDetailedSummary> page, LogisticsOrderDetailedSummary htLogisticsOrderDetail) {
//		htLogisticsOrderDetail.setPage(page);
//		page.setList(dao.getLogisticsOrderDetailedSummaryList(htLogisticsOrderDetail));
//		return page;
//	}
	/**
	 * @description findListByProfit
	 * @date 2018-10-26
	 * @author chuming
	 * @param htLogisticsOrderDetail
	 * @return
	 */
//	public Page<LogisticsOrderDetailedSummary> getSupplierSummaryPage (Page<LogisticsOrderDetailedSummary> page, LogisticsOrderDetailedSummary htLogisticsOrderDetail) {
//		htLogisticsOrderDetail.setPage(page);
//		page.setList(dao.getSupplierSummaryList(htLogisticsOrderDetail));
//		return page;
//	}

	/**
	 * @description findListByProfit
	 * @date 2018-10-26
	 * @author chuming
	 * @param htLogisticsOrderDetail
	 * @return
	 */
	public List<LogisticsOrderDetailedSummary> getLogisticsOrderDetailedSummaryList ( LogisticsOrderDetailedSummary htLogisticsOrderDetail) {
		return dao. getLogisticsOrderDetailedSummaryList(htLogisticsOrderDetail);
	}

	/**
	 * @description findListByProfit
	 * @date 2018-10-26
	 * @author chuming
	 * @param htLogisticsOrderDetail
	 * @return
	 */
	public List<LogisticsOrderDetailedSummary> getSupplierSummaryList ( LogisticsOrderDetailedSummary htLogisticsOrderDetail) {
		return dao. getSupplierSummaryList(htLogisticsOrderDetail);
	}

	/**
	 * @description findListByProfit
	 * @date 2018-10-26
	 * @author chuming
	 * @param htLogisticsOrderDetail
	 * @return
	 */
//	public Page<HtLogisticsOrderDetail> findListByProfitPage (Page<HtLogisticsOrderDetail> page, HtLogisticsOrderDetail htLogisticsOrderDetail) {
//		htLogisticsOrderDetail.getSqlMap().put("dsf", BaseService.dataScopeFilter(htLogisticsOrderDetail.getCurrentUser(), "o3", "u"));
//		htLogisticsOrderDetail.setPage(page);
//		page.setList(dao.findListByProfit(htLogisticsOrderDetail));
//		return page;
//	}

	@Transactional(readOnly = false)
	public void saveShippingOrderform(HtLogisticsOrderDetail htLogisticsOrderDetail){
		htLogisticsOrderDetailDao.updateOrderInfo(htLogisticsOrderDetail);
	}

//	public Page<HtLogisticsOrderDetail> findStatisticalListByPage (Page<HtLogisticsOrderDetail> page, HtLogisticsOrderDetail htLogisticsOrderDetail) {
//		//htLogisticsOrderDetail.getSqlMap().put("dsf", BaseService.dataScopeFilter(htLogisticsOrderDetail.getCurrentUser(), "o3", "u"));
//		htLogisticsOrderDetail.setPage(page);
//		page.setList(htLogisticsOrderDetailDao.findStatisticalList(htLogisticsOrderDetail));
//		return page;
//	}
	public String getOriginalNumber(HtLogisticsOrderDetail originalNumber){
		return htLogisticsOrderDetailDao.getOriginalNumber(originalNumber);
	}
	/**
	 * 根据Id条件更新数据
	 * @param htLogisticsOrderDetail
	 * @return
	 */
	public int updateInfoById(HtLogisticsOrderDetail htLogisticsOrderDetail) {
		return htLogisticsOrderDetailDao.updateInfoById(htLogisticsOrderDetail);
	}
	/**
	 * 根据货主合同Id查询最初生成的车队合同
	 * @param orderId
	 * @return
	 */
	public HtLogisticsOrderDetail selectFirstByOrderId(String orderId){
		return htLogisticsOrderDetailDao.selectFirstByOrderId(orderId);
	}

	/**
	 * @author llh
	 * @description 小程序司机接单查看货源详情
	 */
	public HtLogisticsOrderDetail selectDetailById(HtLogisticsOrderDetail htLogisticsOrderDetail){
		return htLogisticsOrderDetailDao.selectDetailById(htLogisticsOrderDetail);
	}

	public List<Map<String,Object>> selectShippingOrderList(HtLogisticsOrderDetail htLogisticsOrderDetail){
		return htLogisticsOrderDetailDao.findShippingOrderList(htLogisticsOrderDetail);
	}

	/**
	 * @author 作者: yangjy
	 * @description 描述: 托运单查看详情
	 * @date 时间: 2023/5/24 20:13
	 * @return 返回值: HtLogisticsOrderDetail
	 */
	public HtLogisticsOrderDetail findListById(HtLogisticsOrderDetail htLogisticsOrderDetail){
		return htLogisticsOrderDetailDao.findListById(htLogisticsOrderDetail);
	}

	/**
	 * @Description 查询货主托运单列表
	 * @Author wlxiang
	 * @Date 19:15 2023/6/7
	 * @Param
	 * @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
	 **/
	public List<Map<String,Object>> selectConsignerLogisticsOrderDetailList(HtLogisticsOrderDetail htLogisticsOrderDetail){
		return htLogisticsOrderDetailDao.selectConsignerLogisticsOrderDetailList(htLogisticsOrderDetail);
	}
	
	/**
	 * @author llh
	 * @date 2023/6/19
	 * @return java.util.Map<java.lang.String,java.lang.Object>
	 * @description 小程序货主查询托运单详情      
	 */
	public Map<String,Object> getLogisticsInfo(String logisticsId){
		return htLogisticsOrderDetailDao.getLogisticsInfo(logisticsId);
	}

	/**
	 * @author llh
	 * @date 2023/7/3
	 * @return java.util.Map<java.lang.String,java.lang.Object>
	 * @description 查询当前司机对应部门所有货源信息      
	 */
	public List<Map<String,Object>> findDriverGoods(HtLogisticsOrderDetail htLogisticsOrderDetail){
		return htLogisticsOrderDetailDao.findDriverGoods(htLogisticsOrderDetail);
	}
}